////
////  CMDBHomeLeftViewController.swift
////  CMDB
////
////  Created by 曹桂祥 on 17/4/13.
////  Copyright © 2017年 CMDB. All rights reserved.
////

import UIKit

private let ratio : CGFloat = 0.86

class CMDBHomeLeftViewController: CMDBBaseViewController {
    
    var nav : CustomNavigationControllerViewController?
    
    weak var sliderVc : CMDBHomeBaseViewController?
    
    var userInfo : CMDBUserInfoBean?
    
    var leftMenuArr : [String]?
    
    var bottomView : UIView!
    
    var sliderView : SliderView!
    
    override func setup() {
        super.setup()
        
        view.backgroundColor = UIColor.whiteColor()
        
        let leftMenuArr : [String] = ["我的作品","我的资料","我的档期","我的动态","我的日记","我的相册","我的收藏"]
        
        self.leftMenuArr = leftMenuArr
        
        setupSliderView()
        
        loadRequest()
        
    }
}

extension CMDBHomeLeftViewController{
    
    func setupSliderView(){
        
        sliderView = SliderView(frame: CGRect(x:0, y: 0, width: CMDB_Screen_Width + 15, height: CMDB_Screen_Height))
        
        sliderView.superNav = nav
        
        view.addSubview(sliderView)
        
        sliderView.showSliderBlock = {(
            
            UIView.animateWithDuration(0.2, animations: {
                self.sliderView.shadowView.alpha = 0.55
            })
            
        )}
    }
}


extension CMDBHomeLeftViewController {
    
    func loadRequest(){
        
        let getinforPara = CMDBUserInfoParam()
        
        do {
            
            try CMDBUserInfoManager.getInstance.queryUserInfo(getinforPara, handler: {[weak self] (userInfo) in
                self!.sliderView.setupUserData(userInfo)
                
                self!.sliderVc!.testBtn!.kf_setImageWithURL(NSURL(string: userInfo.icon), forState: .Normal)
                
                }, error: { (rescode) in
                    
                }, failure: {
                    
            })
            
        }catch {
            
        }
        
    }
    
}


extension CMDBHomeLeftViewController{
    
    
}

extension CMDBHomeLeftViewController{
    
    func tapGestureOnImageView(imageView : UIImageView){
        
        let gester = UITapGestureRecognizer(target: self, action: #selector(tapOnView))
        
        imageView.addGestureRecognizer(gester)
    }
    
}


//MARK:- method action
extension CMDBHomeLeftViewController{
    
        
    @objc func tapOnView(){
        
        self.dataBlock!("headIcon",0,true)
        
        printLog("tapOnView")
    }
    
    
}
